import jwt from "jsonwebtoken";
import { JWT_SECRET } from "../configs/yz";
import { usersTable } from "../database/users-table";

export const decodeToken = (token: string) => {
	const userId = Number(jwt.verify(token.replace("Bearer ", ""), JWT_SECRET)) || null;
	return userId ? usersTable.getUser(userId) : null;
};
